Repository navigation
CKS: set kube-apiserver and kubelet options at create time - #14783
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
createKubernetesCluster gains three optional parameters: | parameter | type | used for | |---|---|---| | apiserverargs | map | kube-apiserver flags, e.g. OIDC (oidc-issuer-url, oidc-client-id, ...) | | kubeletconfig | JSON object | KubeletConfiguration fields, e.g. systemReserved, kubeReserved, evictionHard | | auditpolicy | string | audit Policy document; turns on audit logging | - Stored in kubernetes_cluster_details and returned in the cluster response. No schema change. - Rendered into the kubeadm init config (ClusterConfiguration apiServer.extraArgs and extraVolumes, plus a KubeletConfiguration document), not into shell flags. - kubeadm uploads the kubelet config to the kubelet-config ConfigMap, so nodes that join later (scale, HA control nodes) get the same settings. The audit policy file is also written on the extra control nodes. - Audit logs go to /var/log/kubernetes/audit with rotation defaults (maxage 30, maxbackup 3, maxsize 100 MB) that apiserverargs can override. The policy is written gzip+base64 encoded. - kubeadm config is now built in Java for both the external etcd and the stacked case, as kubeadm.k8s.io/v1beta3, or v1beta4 for Kubernetes 1.31+. The stacked case keeps the old flag based kubeadm init unless one of the new parameters is set. - Validation: flag names [a-z0-9-], values and kubelet strings limited to a plain character set (no spaces, quotes, braces), flags and kubelet fields CloudStack relies on (secure-port, etcd-servers, anonymous-auth, audit-policy-file, cgroupDriver, clusterDNS, requestheader-*, ...) reserved, NodeRestriction kept in enable-admission-plugins, Kubernetes 1.22+, rejected for ExternalManaged clusters, duplicate flags rejected. - kubeadm-config.yaml is now 0600: it holds the bootstrap token and certificate key. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14783 +/- ##
============================================
+ Coverage 20.80% 20.82% +0.01%
- Complexity 20919 20969 +50
============================================
Files 6053 6054 +1
Lines 548451 548704 +253
Branches 78719 73322 -5397
============================================
+ Hits 114128 114285 +157
- Misses 420958 421038 +80
- Partials 13365 13381 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
createKubernetesCluster gains three optional parameters:
apiserverargsoidc-issuer-url,oidc-client-id, ...)kubeletconfigsystemReserved,kubeReserved,evictionHardauditpolicykubernetes_cluster_detailsand returned in the cluster response. No schema change.kubeadm.k8s.io/v1beta3, or v1beta4 for Kubernetes 1.31+.apiServer.extraArgs/extraVolumesplus a KubeletConfiguration document, not into shell flags.kubeadm initunless one of the new parameters is set.kubelet-configConfigMap, so nodes that join later (scale, extra control nodes) get the same settings. The audit policy file is also written on the extra control nodes./var/log/kubernetes/auditwith rotation defaults (maxage 30, maxbackup 3, maxsize 100 MB) thatapiserverargscan override.[a-z0-9-]. Values and kubelet strings are limited to a plain character set (no spaces, quotes or braces).secure-port,etcd-servers,anonymous-auth,audit-policy-file,requestheader-*,cgroupDriver,clusterDNS,staticPodURL.NodeRestrictionstays inenable-admission-plugins.kubeadm-config.yamlis now 0600, since it holds the bootstrap token and certificate key.Fixes #14782
Types of changes
How Has This Been Tested?
Unit tests: 155 in the kubernetes-service module, 27 of them in
KubeadmConfigBuilderTest(v1beta3/v1beta4 output, stacked and external etcd, validation and reserved names).KVM lab (build that also carried other pending CKS changes), Kubernetes v1.33.13, HA cluster (2 control + 1 worker) created with OIDC
apiserverargs, akubeletconfigwithsystemReservedandevictionHard, and a Metadata-levelauditpolicy:--oidc-issuer-url,--oidc-client-id,--audit-policy-file,--audit-log-*defaults,--enable-admission-plugins=NodeRestriction/var/log/kubernetes/audit/audit.logwritten, Metadata-level events/var/lib/kubelet/config.yamlsystemReservedandevictionHardas givenkubeadm-config.yaml